<template>
<div class="container">
  <div class="search-bar">
    <router-link :to="{path:'/SearchDep',query:{productId:productId}}" class="search-inner">
      <img src="../assets/images/search1@2x.png" alt="">
      <input type="text" placeholder="搜索营业部门">
    </router-link>
  </div>
  <div class="dep-wrap">
    <!-- <div class="sub-wrap">
      <div class="title">A</div>
      <div class="list-wrap">
        <div class="list">安庆市黄兴营业部</div>
        <div class="list">安庆市黄兴营业部</div>
      </div>
    </div> -->
    
    <div class="sub-wrap" v-for="item in group">
      <div class="title" v-text="item.letterType"></div>
      <div class="list-wrap">
        <div class="list" 
          v-for="list in item.data" 
          v-text="list.branchName"
          @click="tapItem(list.branchName,list.branchCode)"
          :key="list.branchCode"></div>
      </div>
    </div>

    
  </div>
</div>
</template>

<script>
import Api from '@/service';

export default {
  name: 'SelectDep',
  data () {
    return {
      productId: this.$route.query.productId,
      group: []
    }
  },
  methods:{
    initDep(){
      let _self = this;
      Api.sm.initDep()
      .then(function(response){
        console.log(response.data.info);
        // let _result = response.data.data;
        _self.group = response.data.info;
      });
    },
    tapItem(branchName,branchCode){
      this.$router.push({path:'/Select',query:{productId:this.productId,branchName:branchName,branchCode:branchCode}});
    }

  },
  created: function(){
    this.initDep();
  }
}
</script>

<style lang="scss" scoped type="text/css">
@import  "../assets/scss/reset";
.container{
  width: 100%;
  background: #F5F8FA;
  overflow: hidden;
  box-sizing: border-box;
  .search-bar{
    width: 100%;
    background:white;
    height: calculateRem(54px);
    padding: calculateRem(9px) calculateRem(16px);
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    right: 0;
    box-sizing: border-box;
    border-bottom: 1px solid #f1f1f1;
    .search-inner{
      display: block;
      width: 100%;
      height: calculateRem(36px);
      box-sizing: border-box;
      border-radius: 2px;
      border: 1px solid #E1E5E8;
      >img{
        width: calculateRem(14px);
        height: calculateRem(14px);
        margin-right: calculateRem(9px);
        margin-left: calculateRem(11px);
        vertical-align: text-top;
      }
      >input{
        width: 80%;
        height: calculateRem(34px);
        box-sizing: border-box;
        outline: none;
        border: transparent;
        font-size: calculateRem(16px);
        color: #333;

      }
    }
  }
  .dep-wrap{
    width: 100%;
    height: auto;
    padding-top: calculateRem(54px);
    padding-bottom: calculateRem(20px);
    .sub-wrap{
      width: 100%;
      height: auto;
      .title{
        width: 100%;
        height: calculateRem(30px);
        line-height: calculateRem(30px);
        color: #E62622;
        font-size: calculateRem(18px);
        box-sizing: border-box;
        padding: 0 calculateRem(16px);
        background: #F5F8FA;

      }
      .list-wrap{
        background: white;
        box-sizing: border-box;
        padding: 0 calculateRem(16px);

        .list{
          box-sizing: border-box;
          border-bottom: 1px solid #f1f1f1;
          width: 100%;
          height: calculateRem(47px);
          line-height: calculateRem(47px);
          color: #333;
          font-size: calculateRem(17px);
          &:active{
            background: #fcfcfc;
          };
        }
      }
      
    }
  }
}
</style>
